package GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

public class TerminalAgencia {

	private JFrame frame;
	private JPanel panel;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TerminalAgencia window = new TerminalAgencia();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public TerminalAgencia() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 465, 355);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		panel = new JPanel();
		frame.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
		
		JMenuBar menuBar = new JMenuBar();
		frame.setJMenuBar(menuBar);
		
		JMenu mnMenu = new JMenu("Menu");
		menuBar.add(mnMenu);
		
		JMenuItem mntmSalir = new JMenuItem("Salir");
		mntmSalir.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0); 
			}
		});
		mnMenu.add(mntmSalir);
		
		JMenu mnTickets = new JMenu("Tickets");
		menuBar.add(mnTickets);
		
		JMenuItem mntmVentas = new JMenuItem("Ventas");
		mntmVentas.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				PanelVenta panelVenta = new PanelVenta();
				frame.getContentPane().removeAll();
				frame.getContentPane().add(panelVenta, BorderLayout.CENTER);
				//frame.setAlignmentX(panelVenta.CENTER_ALIGNMENT);
				//frame.setLocation(PanelVenta.HEIGHT/2, PanelVenta.WIDTH/2);
				frame.revalidate();
				
			}
		});
		
		mnTickets.add(mntmVentas);
		
		JMenuItem mntmAnulaciones = new JMenuItem("Anulaciones");
		mntmAnulaciones.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				PanelAnulacion panelAnulacion = new PanelAnulacion();
				frame.getContentPane().removeAll();
				frame.getContentPane().add(panelAnulacion, BorderLayout.CENTER);
				frame.revalidate();
			}
		});
		mnTickets.add(mntmAnulaciones);
	}
}
